package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjWorkStatementTemplateFieldContent;
import com.zb.mapper.ZjWorkStatementTemplateFieldContentMapper;
import com.zb.service.ZjWorkStatementTemplateFieldContentService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 工单结单模板字段内容表，该表存储字段类型为：单选、多选的内容 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-10-07
 */
@Service
public class ZjWorkStatementTemplateFieldContentServiceImpl extends ServiceImpl<ZjWorkStatementTemplateFieldContentMapper, ZjWorkStatementTemplateFieldContent> implements ZjWorkStatementTemplateFieldContentService {

    // 根据工单结单模板字段表ID获取字段内容
    @Override
    public List<ZjWorkStatementTemplateFieldContent> getByWorkStatementTemplateFieldIds(List<Long> workStatementTemplateFieldIds) {
        if (null == workStatementTemplateFieldIds || workStatementTemplateFieldIds.isEmpty()) {
            return new ArrayList<>();
        }
        QueryWrapper<ZjWorkStatementTemplateFieldContent> wrapper = new QueryWrapper<>();
        wrapper.select("id", "work_statement_template_field_id", "val");
        wrapper.in("work_statement_template_field_id", workStatementTemplateFieldIds);
        return this.list(wrapper);
    }

    // 根据工单结单模板字段表ID获取字段内容
    @Override
    public List<ZjWorkStatementTemplateFieldContent> getByWorkStatementTemplateFieldId(Long workStatementTemplateFieldId) {
        QueryWrapper<ZjWorkStatementTemplateFieldContent> wrapper = new QueryWrapper<>();
        wrapper.select("id", "work_statement_template_field_id", "val");
        wrapper.eq("work_statement_template_field_id", workStatementTemplateFieldId);
        return this.list(wrapper);
    }

    // 根据工单结单模板字段表ID删除
    @Override
    public void dleteBatchByWorkStatementTemplateFieldIds(List<Long> workStatementTemplateFieldIds) {
        if (null == workStatementTemplateFieldIds || workStatementTemplateFieldIds.isEmpty()) {
            return;
        }
        QueryWrapper<ZjWorkStatementTemplateFieldContent> wrapper = new QueryWrapper<>();
        wrapper.in("work_statement_template_field_id", workStatementTemplateFieldIds);
        this.remove(wrapper);
    }
}
